package com.gxa.community.customer.controller.classification;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.gxa.community.customer.service.classification.ClassificationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@Api("客户端底部分类模块")
@RequestMapping("/classification")
public class ClassificationController {

    @Autowired
    private ClassificationService classificationService;


    @ApiOperation("获取所有分类且包含商品详情")
    @GetMapping("/queryallclassificationcontaingoodsinfo")
    public String queryAllClassificationContainGoodsInfo(){
        return classificationService.queryAllClassificationContainGoodsInfo();
    }

    @ApiOperation("获取热词（在分类页面点击搜索框时）")
    @GetMapping("/queryallhotword")
    public String queryAllHotWord() throws JsonProcessingException {
        String result = classificationService.getAllHotWords();
        return result;
    }

    @ApiOperation("分类页面搜索框点击搜索时搜索商品的接口（根据商品名称进行搜索）")
    @GetMapping("/searchgoods")
    public String searchGoods(String name) throws JsonProcessingException {
        String data = classificationService.searchGoods(name);
        return data;
    }

}
